﻿
using Mono.Cecil;

public abstract class CallAstTree : LuaAstTree
{
    public LuaMethodReference Method { get; }
    public LuaAstTree[] Parameters { get; }
    public CallAstTree(LuaMethodReference method, LuaAstTree[] parameters)
    {
        Method = method;
        Parameters = parameters;
        ResultType = method.ReturnType;
    }
    public override void WriteTo(ICodeWriter writer)
    {
        writer.Code($"{Method.Name}(");
        for (int i = 0; i < Parameters.Length; i++)
        {
            if (i > 0)
                writer.Code(", ");
            Parameters[i].WriteTo(writer);
        }
        writer.Code(")");
    }
}

